package April._23.work3;

import java.io.*;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class MyTimerTask extends TimerTask {
    FileOutputStream out;

    public MyTimerTask(FileOutputStream out) {
        this.out = out;
    }

    @Override
    public void run() {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = new Date();
        System.out.println("currentDateTime = " + date);
        try {
            out.write(String.valueOf(date).getBytes());
            out.write(System.lineSeparator().getBytes());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
}
